// ===== 设计系统 - 样式混入 =====

// 卡片样式混入
@mixin card-base {
  background: var(--bg-primary);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  transition: var(--transition-normal);
}

@mixin card-hover {
  &:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
  }
}

@mixin card {
  @include card-base;
  @include card-hover;
}

// 渐变背景混入
@mixin gradient-primary {
  background: var(--gradient-primary);
}

@mixin gradient-page {
  background: var(--gradient-page);
}

@mixin gradient-text($gradient: var(--gradient-primary)) {
  background: $gradient;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

// 按钮样式混入
@mixin button-base {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  border: none;
  border-radius: var(--border-radius-md);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: var(--transition-normal);
  text-decoration: none;
  
  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
  }
}

@mixin button-primary {
  @include button-base;
  @include gradient-primary;
  color: white;
  
  &:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
  }
  
  &:active {
    transform: translateY(0);
  }
}

@mixin button-secondary {
  @include button-base;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  
  &:hover:not(:disabled) {
    background: var(--bg-muted);
    border-color: var(--primary-color);
  }
}

@mixin button-ghost {
  @include button-base;
  background: transparent;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
  
  &:hover:not(:disabled) {
    @include gradient-primary;
    color: white;
  }
}

// 尺寸混入
@mixin size-sm {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
}

@mixin size-md {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-size-md);
}

@mixin size-lg {
  padding: var(--space-lg) var(--space-xl);
  font-size: var(--font-size-lg);
}

// 装饰元素混入
@mixin floating-decoration($size: 80px, $color: rgba(255, 255, 255, 0.1)) {
  position: absolute;
  width: $size;
  height: $size;
  border-radius: 50%;
  background: $color;
  animation: float 6s ease-in-out infinite;
  pointer-events: none;
}

@mixin traffic-lights {
  &::before {
    content: '';
    position: absolute;
    top: 12px;
    left: 12px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ff5f56;
    box-shadow:
      20px 0 0 #ffbd2e,
      40px 0 0 #27c93f;
  }
}

// 文本截断混入
@mixin text-ellipsis($lines: 1) {
  @if $lines == 1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  } @else {
    display: -webkit-box;
    -webkit-line-clamp: $lines;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

// 布局混入
@mixin center-flex {
  display: flex;
  align-items: center;
  justify-content: center;
}

@mixin space-between-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@mixin space-around-flex {
  display: flex;
  align-items: center;
  justify-content: space-around;
}

@mixin space-evenly-flex {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
}

@mixin center-absolute {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

// 间距混入
@mixin space-y($gap) {
  > * + * {
    margin-top: $gap;
  }
}

@mixin space-x($gap) {
  > * + * {
    margin-left: $gap;
  }
}

// 响应式字体
@mixin responsive-font($min-size, $max-size, $min-width: 320px, $max-width: 1200px) {
  font-size: #{$min-size}px;
  
  @media (min-width: #{$min-width}px) and (max-width: #{$max-width}px) {
    font-size: calc(#{$min-size}px + #{$max-size - $min-size} * ((100vw - #{$min-width}px) / #{$max-width - $min-width}));
  }
  
  @media (min-width: #{$max-width}px) {
    font-size: #{$max-size}px;
  }
}

// 滚动条样式
@mixin custom-scrollbar($width: 8px, $track-color: var(--bg-muted), $thumb-color: var(--primary-color)) {
  &::-webkit-scrollbar {
    width: $width;
    height: $width;
  }
  
  &::-webkit-scrollbar-corner {
    background-color: transparent;
  }
  
  &::-webkit-scrollbar-thumb {
    background-color: $thumb-color;
    border-radius: calc($width / 2);
    
    &:hover {
      background-color: var(--primary-dark);
    }
  }
  
  &::-webkit-scrollbar-track {
    border-radius: calc($width / 2);
    background-color: $track-color;
  }
}

// 输入框样式
@mixin input-base {
  padding: var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: var(--font-size-md);
  transition: var(--transition-normal);
  
  &:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  }
  
  &::placeholder {
    color: var(--text-muted);
  }
}

// 动画关键帧
@keyframes float {
  0%, 100% {
    transform: translateY(0px) scale(1);
    opacity: 0.7;
  }
  50% {
    transform: translateY(-20px) scale(1.1);
    opacity: 0.4;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

// 响应式断点混入
@mixin respond-above($breakpoint) {
  @if $breakpoint == xs {
    @media (min-width: 480px) { @content; }
  } @else if $breakpoint == sm {
    @media (min-width: 640px) { @content; }
  } @else if $breakpoint == md {
    @media (min-width: 768px) { @content; }
  } @else if $breakpoint == lg {
    @media (min-width: 1024px) { @content; }
  } @else if $breakpoint == xl {
    @media (min-width: 1280px) { @content; }
  } @else if $breakpoint == 2xl {
    @media (min-width: 1536px) { @content; }
  } @else {
    @media (min-width: $breakpoint) { @content; }
  }
}

@mixin respond-below($breakpoint) {
  @if $breakpoint == xs {
    @media (max-width: 479px) { @content; }
  } @else if $breakpoint == sm {
    @media (max-width: 639px) { @content; }
  } @else if $breakpoint == md {
    @media (max-width: 767px) { @content; }
  } @else if $breakpoint == lg {
    @media (max-width: 1023px) { @content; }
  } @else if $breakpoint == xl {
    @media (max-width: 1279px) { @content; }
  } @else if $breakpoint == 2xl {
    @media (max-width: 1535px) { @content; }
  } @else {
    @media (max-width: $breakpoint) { @content; }
  }
}

@mixin respond-between($min, $max) {
  @media (min-width: $min) and (max-width: $max) {
    @content;
  }
}